from tools.log import GetLogging

logger = GetLogging().get_logging()


class ApiProduct:
    @staticmethod
    def api_post_product(session, url, json_data):
        try:
            logger.info(f"准备验证商品相关接口 - 接口：{url}")
            header = {"Content-Type": "application/json"}
            logger.info("初始化请求头完成")
            logger.info("开始发送商品相关接口POST请求")
            response = session.post(url, headers=header, json=json_data)
            logger.info(f"请求完成，响应状态码: {response.status_code}")
            return response
        except Exception as e:
            logger.error(f"请求过程发生错误: {str(e)}", exc_info=True)
            raise
